﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ivan_snake
{
     class Food
    {
        private int x { get; set; }
        private int y { get; set; }
        private string foodType = "+";
        public Food(Snake snake)
        {

            Random rnd1 = new Random();
            Random rnd2 = new Random();
            int rW = rnd1.Next(2, Console.WindowWidth - 2);
            int rH = rnd2.Next(2, Console.WindowHeight - 2);
            bool error;
            do
            {
                error = false;
                foreach (var snakeBody in snake)
                {
                    if (snakeBody.X == rW && snakeBody.Y == rH)
                    {
                        error = true;
                        break;
                    }
                }
                if (error)
                {
                    rW = rnd1.Next(2, Console.WindowWidth - 2);
                    rH = rnd2.Next(2, Console.WindowHeight - 2);
                }

            } while (error);

            //return new Food(rW, rH);
           // return new Food(10, 15);
            this.x = 10;
            this.y = 15;
        }
        public Food (int x, int y)
        {
            this.x = x;
            this.y = y;     
        }
         public int X
         {
             get { return x; }
             set { x = value; }
         }
         public int Y
         {
             get { return y; }
             set { y = value; }
         }
         public string FoodType
         {
             get { return foodType; }
             set { foodType = value; }
         }
         public class Point
         {
             public int x;
             public int y;
             Point (int x, int y)
             {
             this.x = x;
             this.y = y;
             }
                 

         }
        

    }
}
